
import axios from "axios";
import { ElMessage } from 'element-plus'
import {usetokenstore} from'@/stores/token.js'
const baseURL ='/api';
const instance=axios.create({baseURL})


//响应拦截器
instance.interceptors.response.use(
    result=>{
        if(result.data.code===0){
        return result.data;
        }
// alert(result.data.msg ? result.data.mess : "事务异常")
ElMessage.error(result.data.msg ? result.data.msg : "事务异常");
//异步的状态化成失败的状态
return Promise.reject(result.data)
},
err=>{
    alert("服务异常");
    return Promise.reject(err);//异步的状态化成失败的状态
}
)

export default instance;